package com.example.lishuai.activityanimationdemo;

import android.app.ActivityOptions;
import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.util.Pair;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity implements View.OnClickListener{

    private Button one;
    private Button two;
    private Button three;
    private ImageView foue;
    private Button five;

    private TextView textView ;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        one = (Button) findViewById(R.id.one);
        two = (Button) findViewById(R.id.two);
        three = (Button) findViewById(R.id.three);
        foue = (ImageView) findViewById(R.id.four);
        five = (Button) findViewById(R.id.five);
        textView = (TextView) findViewById(R.id.textview);
        one.setOnClickListener(this);
        two.setOnClickListener(this);
        three.setOnClickListener(this);
        foue.setOnClickListener(this);
        five.setOnClickListener(this);
    }
    @Override
    public void onClick(View view) {
        Intent intent = new Intent(this,FenJieActivity.class);
        Bundle bundle = new Bundle();
        switch (view.getId()){
            case R.id.one:
                startActivity(new Intent(this,TwoActivity.class));
                overridePendingTransition(R.anim.in,R.anim.out);
                break;

            case R.id.two:
                bundle.putString("key","two");
                intent.putExtras(bundle);
                startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
                break;
            case R.id.three:
                bundle.putString("key","three");
                intent.putExtras(bundle);
                startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
                break;
            case R.id.four:
                //单个view 共享
                //startActivity(new Intent(this,GongXiangActivity.class), ActivityOptions.makeSceneTransitionAnimation(this,view,"mybut_one").toBundle());
                //多个view 共享
                Pair<View, String> mytext = Pair.create((View)textView, "mytext");
                Pair<View, String> mybut_one = Pair.create((View)foue, "mybut_one");
                startActivity(new Intent(this,GongXiangActivity.class), ActivityOptions.makeSceneTransitionAnimation(this,mytext,mybut_one).toBundle());
                break;
            case R.id.five:
                bundle.putString("key","one");
                intent.putExtras(bundle);
                startActivity(intent, ActivityOptions.makeSceneTransitionAnimation(this).toBundle());
                break;
        }
    }
}
